import 'package:flutter/material.dart';
import 'package:yysk_app/pages/nft_pages/market_pages/market_rob_buy/market_rob_buy_page.dart';
import 'package:yysk_app/utils/colors.dart';
import 'package:yysk_app/utils/helper.dart';
import 'package:yysk_app/pages/nft_pages/setting/setting_real_name_auth_page.dart';
import 'package:get/get.dart';
import 'package:yysk_app/widget/image_asset_widget.dart';

class BuildPageView extends StatefulWidget {
  final Widget child;
  final bool hasAuth;
  final bool hasWallet;
  final bool showRob;
  const BuildPageView({
    super.key,
    required this.child,
    required this.hasAuth,
    required this.hasWallet,
    this.showRob = false
  });

  @override
  State<BuildPageView> createState() => _BuildPageViewState();
}

class _BuildPageViewState extends State<BuildPageView>
    with AutomaticKeepAliveClientMixin {
  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Stack(
      children: [
        widget.child,
        if (!widget.hasAuth)
          Positioned(
            bottom: 8,
            left: 12.px,
            right: 12.px,
            child: _buildTips(context, '完成实名认证可有效提高账号安全', '立即实名', '/realName'),
          ),
          if(widget.showRob)Positioned(
            right: 13.px,
            bottom: 24.px,
            child: GestureDetector(
              onTap: (){
                Get.toNamed(MarketRobBuyPage.path);
              },
              child: ImageAssetWidget(imageUrl: 'static/images/market/rob.png',width: 88.px,height: 86.px,),
            ))
        // if (widget.hasAuth && !widget.hasWallet)
        //   Positioned(
        //     bottom: 8,
        //     left: 12.px,
        //     right: 12.px,
        //     child: _buildTips(context, '您还未开通钱包', '去开通', '/myWallet'),
        //   ),
      ],
    );
  }

  Widget _buildTips(
    BuildContext context,
    label,
    String buttonLabel,
    String buttonUrl,
  ) {
    return Container(
      height: 50.px,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(8.px),
        color: Color.fromRGBO(59  , 62, 69, 1),
        // gradient: const LinearGradient(
        //   colors: [AppColors.backgroundColorLightGrey,AppColors.backgroundColorLightGrey],
        // ),
      ),
      child: Padding(
        padding: EdgeInsets.fromLTRB(12.px, 8.px,12.px, 8.px),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Expanded(
              child: Text(
                label,
                style: TextStyle(fontSize: 12.px,color: AppColors.backgroundColorGrey),
                overflow: TextOverflow.ellipsis,
                
              ),
            ),
            GestureDetector(
              onTap: () {
                Get.toNamed(SettingRealNameAuthPage.path);
              },
              child: Container(
                width: 56.px,
                height: 22.px,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(4.px),
                  gradient: LinearGradient(
                    colors: [AppColors.startColor, AppColors.endColor], // 定义渐变颜色
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                  ),
                ),
                child: Center(
                  child: Text(buttonLabel,style: TextStyle(fontSize: 10.px,color: AppColors.backgroundColorBlack,fontWeight: FontWeight.bold),),
                ),
                
              ),
            ),
          ],
        ),
      ),
    );
  }
}
